package io.github.qifan777.server.wallet.root.entity;

import io.github.qifan777.server.infrastructure.jimmer.BaseEntity;
import io.github.qifan777.server.user.root.entity.User;
import io.qifan.infrastructure.generator.core.GenAssociationField;
import io.qifan.infrastructure.generator.core.GenEntity;
import io.qifan.infrastructure.generator.core.GenNumberField;
import jakarta.validation.constraints.Null;
import org.babyfish.jimmer.sql.DissociateAction;
import org.babyfish.jimmer.sql.Entity;
import org.babyfish.jimmer.sql.OnDissociate;
import org.babyfish.jimmer.sql.OneToOne;

import java.math.BigDecimal;

@GenEntity
@Entity
public interface Wallet extends BaseEntity {
    /**
     * 余额
     */
    @GenNumberField(label = "余额", order = 0)
    BigDecimal balance();

    /**
     * 钱包密码
     */
    @Null
    String password();

    @OnDissociate(DissociateAction.DELETE)
    @GenAssociationField(label = "用户", order = 1, prop = "userId")
    @OneToOne
    User user();
}
